import type { UnitCreateDto, UnitDto, UnitUpdateDto } from './models';
import { RestService } from '@abp/ng.core';
import type { PagedResultDto } from '@abp/ng.core';
import { Injectable } from '@angular/core';
import type { FilterGroupRequestDto, FilterRequestDto } from '../core/filters/models';

@Injectable({
  providedIn: 'root',
})
export class UnitService {
  apiName = 'BasicArchives';
  

  create = (input: UnitCreateDto) =>
    this.restService.request<any, UnitDto>({
      method: 'POST',
      url: '/api/basic-archives/unit',
      body: input,
    },
    { apiName: this.apiName });
  

  delete = (id: string) =>
    this.restService.request<any, void>({
      method: 'DELETE',
      url: `/api/basic-archives/unit/${id}`,
    },
    { apiName: this.apiName });
  

  find = (filter: string) =>
    this.restService.request<any, UnitDto>({
      method: 'GET',
      url: '/api/basic-archives/unit/find',
      params: { filter },
    },
    { apiName: this.apiName });
  

  findBySourceKey = (sourceKey: string, sourceType: string) =>
    this.restService.request<any, UnitDto>({
      method: 'GET',
      url: '/api/basic-archives/unit/find-by-source-key',
      params: { sourceKey, sourceType },
    },
    { apiName: this.apiName });
  

  get = (id: string) =>
    this.restService.request<any, UnitDto>({
      method: 'GET',
      url: `/api/basic-archives/unit/${id}`,
    },
    { apiName: this.apiName });
  

  getList = (input: FilterRequestDto) =>
    this.restService.request<any, PagedResultDto<UnitDto>>({
      method: 'GET',
      url: '/api/basic-archives/unit',
      params: { filter: input.filter, sorting: input.sorting, skipCount: input.skipCount, maxResultCount: input.maxResultCount },
    },
    { apiName: this.apiName });
  

  query = (input: FilterGroupRequestDto) =>
    this.restService.request<any, PagedResultDto<UnitDto>>({
      method: 'POST',
      url: '/api/basic-archives/unit/query',
      body: input,
    },
    { apiName: this.apiName });
  

  update = (id: string, input: UnitUpdateDto) =>
    this.restService.request<any, UnitDto>({
      method: 'PUT',
      url: `/api/basic-archives/unit/${id}`,
      body: input,
    },
    { apiName: this.apiName });

  constructor(private restService: RestService) {}
}
